package com.mahees.portfolio.domain

//def f = request.getFile('upfile')
//http://static.springsource.org/spring/docs/2.0.x/api/org/springframework/web/multipart/MultipartHttpServletRequest.html
//http://static.springsource.org/spring/docs/1.2.x/api/org/springframework/web/multipart/MultipartFile.html#getName()
//http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/web/multipart/MultipartRequest.html
class DBFile extends File {
	
	String content
	String name
	
    static constraints = {
		content (nullable: false, blank: false)
		name	(nullable: false, blank: false, unique: true)
    }
	
	def beforeInsert() {
		//dateCreated = new Date()
	}
	
	def beforeUpdate() {
		//lastUpdated = new
	}
	
	void encodeBase64(byte[] fileBytes) {
		this.content = fileBytes.encodeBase64().toString();
	}
	
	byte[] decodeBase64() {
		return this.content.decodeBase64()
	}
	
	
}
